package fr.emn.integration.synthese.controle;


import java.awt.Frame;
	import java.awt.event.ActionEvent;
	import java.awt.event.ActionListener;
	import java.util.Observable;
	import java.util.Observer;

import javax.swing.JButton;

import fr.emn.integration.synthese.abstraction.Cours;
import fr.emn.integration.synthese.presentation.EvaluationDialog;

public class ControlJButtonPlusEvaluation implements Observer, ActionListener {
	
	
		private Cours modele;
		private JButton button;
		private Frame parent;

		public ControlJButtonPlusEvaluation(Frame parent, Cours modele, JButton button) {
			this.modele = modele;
			this.button = button;
			this.parent = parent;
			button.setEnabled(false);
		}

		@Override
		public void actionPerformed(ActionEvent e) {
			EvaluationDialog evaluationDialog = new EvaluationDialog(parent, modele, true);
			evaluationDialog.setVisible(true);
		}

		@Override
		public void update(Observable o, Object message) {
			Integer iMessage = (Integer) message;
			if (iMessage == Cours.CHANGEMENT_GROUPE_COURANT) {
				if (modele.getGroupeCourante() == -1)
					button.setEnabled(false);
				else
					button.setEnabled(true);
			}
		}

	}


